package com.liqw.service;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.kafka.support.ProducerListener;
import org.springframework.stereotype.Component;

/**
 * 类说明：
 */
@Slf4j
@Component
public class SendInfo implements ProducerListener {
    
    public void onSuccess(String topic, Integer partition, Object key, Object value, RecordMetadata recordMetadata) {
        System.out.println(String.format("主题：{}，分区：{}，偏移量：{}，key：{}，value：{}",
                recordMetadata.topic(),
                recordMetadata.partition(),
                recordMetadata.offset(),
                key,
                value));
        
    }
    
    public void onError(String topic, Integer partition, Object key, Object value, Exception exception) {
        exception.printStackTrace();
    }
}
